﻿
@{
    ViewBag.Title = "找回密码 - 果壳园";
    Layout = "~/Areas/Admin/Views/Shared/_AccountLayout.cshtml";
}
@model Nutshell.Blog.Model.ViewModel.ForgetPwd
@if (ViewBag.Error != null)
{
    <div class="top-error">@ViewBag.Error</div>
}
<h2 class="title">找回密码</h2>
<div>
    @*<form>
            <div class="ctrl-group">
                <label>登录账号</label>
                <div>
                    <input type="text" name="name" id="name" />
                </div>
            </div>
            <div class="ctrl-group">
                <label>验证码</label>
                <div id="code_box">
                    <input type="text" name="code" id="txtCode" />
                </div>
                <img id="img_code" title="点击更换验证码" src="/account/getValidCode" alt="验证码加载失败" onclick="changecode()" />
            </div>
            <div class="ctrl-btns">
                <input type="button" id="btnNext" value="下一步" class="btn-submit" />
            </div>
        </form>*@
    @using (Ajax.BeginForm("forgetPassword", new AjaxOptions { HttpMethod = "POST", OnBegin = "btn_loading('验证中')", OnSuccess = "success", OnFailure = "btn_loaded('下一步')" }))
    {
        <div class="ctrl-group">
            @Html.LabelFor(m => m.UserName)
            <div>
                @Html.TextBoxFor(m => m.UserName)
            </div>
            @Html.ValidationMessageFor(m => m.UserName, null, new { @class = "error" })
        </div>
        <div class="ctrl-group">
            @Html.LabelFor(m => m.Code)
            <div id="code_box">
                @Html.TextBoxFor(m => m.Code, new { id = "txtCode" })
            </div>
            @Html.ValidationMessageFor(m => m.Code, null, new { @class = "error" })
            <img id="img_code" title="点击更换验证码" src="/account/getValidCode" alt="验证码加载失败" onclick="changecode()" />
        </div>
        <div class="ctrl-btns">
            <input type="submit" id="btnNext" value="下一步" class="btn-submit" />
        </div>
    }
</div>
@section script{
    <script>
        function success(data) {
            btn_loaded('下一步');
            if (data.code == 0) {
                location = data.res;
            } else {
                changecode();
                alert(data.msg);
            }
        }
    </script>
}